package com.atguigu.guli.service.statistics.controller.admin;


import com.atguigu.guli.common.base.result.R;
import com.atguigu.guli.service.statistics.service.DailyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 * 网站统计日数据 前端控制器
 * </p>
 *
 * @author Helen
 * @since 2021-10-10
 */
@Api(description = "统计分析管理")
@RestController
@RequestMapping("/admin/statistics/daily")
public class DailyController {

    @Autowired
    private DailyService dailyService;

    @ApiOperation("生成统计记录")
    @PostMapping("create/{day}")
    public R createdStatisticsByDay(
            @ApiParam("统计日期")
            @PathVariable("day")
            String day){
        dailyService.createStatisticsByDay(day);
        return R.ok().message("统计数据生成成功");

    }
    @ApiOperation("展示统计数据")
    @GetMapping("show-chart/{beginDay}/{endDay}")
    public R showChart(
            @ApiParam("开始时间")
            @PathVariable("beginDay") String beginDay,
            @ApiParam("结束时间")
            @PathVariable("endDay") String endDay){

        Map<String, Map<String, Object>> chartDate = dailyService.getChartDate(beginDay, endDay);

        return R.ok().data("chartData",chartDate);


    }
}

